package com.mrd.gtimpframe.action;

import com.mrd.base.Jqgrid;
import com.mrd.gtimpframe.service.OriginalDeclarationBiz;

import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;


/**
 * Created by dengdc on 2017/7/19.
 */
@Controller
@RequestMapping("/original/declaration")
public class OriginalDeclarationAction {
    @Resource
    private OriginalDeclarationBiz originalDeclarationBiz;

    @RequestMapping("listPage")
    public String listPage(){
        return "/gtimpframe/originalDeclaration/listPage";
    }

    /**
     * 获取备份列表清单
     * @param jqgrid
     * @return
     */
    @RequestMapping("/getListPageData")
    @ResponseBody
    public Page<Map<String, Object>> getListPageData(Jqgrid jqgrid){
        //分页
        jqgrid.pageWithMybatis();

        //组装查询条件
        Map<String, Object> parameterMap = jqgrid.getFilterMap();

        //排序
        jqgrid.sortWithMybatis();
        return originalDeclarationBiz.listPageData(jqgrid.getPage(), parameterMap);
    }

    /**
     * 下载对应的pdf文件
     * @param response
     * @param orginalId
     */
    @RequestMapping("/download")
    @ResponseBody
    public void downloadPdfFile(HttpServletResponse response, String date, String pdfName, String orginalId){
        originalDeclarationBiz.downloadPdfFile(response, date, pdfName, orginalId);
    }
}
